//
//  HomeMDCell.m
//  YUXiu
//
//  Created by wang on 16/6/25.
//  Copyright © 2016年 Wang. All rights reserved.
//

#import "HomeMDCell.h"

@interface HomeMDCell ()

@property(nonatomic,strong)UIImageView *imgView;
@property(nonatomic,strong)UILabel *stateLabel;
//@property(nonatomic,strong)UIImageView *hdImgView;
@property(nonatomic,strong)UIButton *hdImgView;

@property(nonatomic,strong)UIButton *playBtn;
@property(nonatomic,strong)UILabel *titleName;
@property(nonatomic,strong)UILabel *numWatch;

@end
@implementation HomeMDCell
// 240
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //
        self.backgroundColor = kWhiteCOLOR;
        
        _imgView = [[UIImageView alloc]initWithFrame:krect(0, 0, kScreenWidth-20, 180)];
        [self.contentView addSubview:_imgView];
        
        _stateLabel = [[UILabel alloc]initWithFrame:krect(_imgView.golf_right-65, 20, 60, 22)];
        _stateLabel.textColor = kWhiteCOLOR;
        _stateLabel.font = Font(12);
        _stateLabel.backgroundColor = kGrayCOLOR;
        _stateLabel.textAlignment = NSTextAlignmentCenter;
        _stateLabel.layer.cornerRadius = 5;
        _stateLabel.clipsToBounds = YES;
        [self.contentView addSubview:_stateLabel];
        
        _hdImgView = [[UIButton alloc]initWithFrame:krect(15, _imgView.golf_bottom+5, 50, 50)];
        [_hdImgView addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
        _hdImgView.layer.cornerRadius = 25;
        _hdImgView.clipsToBounds = YES;
        [self.contentView addSubview:_hdImgView];
        
        _playBtn = [[UIButton alloc]initWithFrame:krect(_hdImgView.golf_right+10, _hdImgView.golf_top+10, 24, 24)];
        _playBtn.layer.cornerRadius = 12;
        _playBtn.clipsToBounds = YES;
        [_playBtn setBackgroundImage:[UIImage imageNamed:@"header"] forState:UIControlStateNormal];
        [self.contentView addSubview:_playBtn];
        
        _numWatch = [[UILabel alloc]initWithFrame:krect(_imgView.golf_right-100, _hdImgView.golf_top+10, 100, 24)];
        _numWatch.textColor = kOrangeCOLOR;
        _numWatch.font = Font(14);
        [self.contentView addSubview:_numWatch];
        
        
        _titleName = [[UILabel alloc]init];
        _titleName.font = Font(14);
        [self.contentView addSubview:_titleName];
        
        [_titleName mas_makeConstraints:^(MASConstraintMaker *make) {
            //
            make.left.equalTo(_playBtn.mas_right).with.offset(0);
            make.right.equalTo(_numWatch.mas_left).with.offset(0);
            make.height.equalTo(@(24));
            make.centerY.equalTo(_numWatch);
        }];
        
        UIView *line = [[UIView alloc]initWithFrame:krect(2, 239, kScreenWidth-24, 1)];
        line.backgroundColor = kGrayCOLOR;
        [self.contentView addSubview:line];
    }
    
    
    return self;
    
}
-(void)layoutSubviews{
    [_imgView setImage:[UIImage imageNamed:@"nopoto160x200"]];
    _stateLabel.text = @"直播";
    [_hdImgView setBackgroundImage:[UIImage imageNamed:@"header"] forState:UIControlStateNormal];
    _numWatch.text = @"8088人观看";
    _titleName.text = @"中国最美瑜珈教练";
}
-(void)click{
    if (_block) {
        
        _block();
    }
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
